﻿<Window x:Class="AsfMojoUI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:asfView="clr-namespace:AsfMojoUI.View"
        xmlns:asfViewModel="clr-namespace:AsfMojoUI.ViewModel"
        xmlns:asfExtControls ="clr-namespace:AsfMojoUI"
        xmlns:converter="clr-namespace:AsfMojoUI.Converter"
        xmlns:asfParsing="clr-namespace:AsfMojo.Parsing;assembly=AsfMojo"
        xmlns:asfMedia="clr-namespace:AsfMojo.Media;assembly=AsfMojo"
        Title="{Binding Title}"
        Height="700"
        Width="1200"
        Icon="AsfMojo.ico"
        DataContext="{Binding Main, Source={StaticResource Locator}}">
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Window.InputBindings>
        <KeyBinding Command="Copy" Modifiers="Control" Key="C" />
    </Window.InputBindings>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <asfView:AboutDialog VerticalAlignment="Stretch"  HorizontalAlignment="Stretch" Margin="0,0,0,0" Panel.ZIndex="100" 
	                                  Visibility="{Binding AboutInfoVisible, Converter={StaticResource BoolToVisibilityConverter}}"
	                                  x:Name="AboutDialogControl"/>
        <asfView:BusyDialog VerticalAlignment="Stretch"  HorizontalAlignment="Stretch" Margin="0,0,0,0" Panel.ZIndex="100" 
	                                  Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibilityConverter}}"
	                                  x:Name="BusyDialogControl"/>
        <asfView:ErrorDetailsDialog VerticalAlignment="Stretch"  HorizontalAlignment="Stretch" Margin="0,0,0,0" Panel.ZIndex="100" 
	                                  Visibility="{Binding ErrorDetailsVisible, Converter={StaticResource BoolToVisibilityConverter}}"
	                                  x:Name="ErrorDetailsDialogControl"/>

        <asfView:ImageDialog VerticalAlignment="Stretch"  HorizontalAlignment="Stretch" Margin="0,0,0,0" Panel.ZIndex="100" 
	                                  Visibility="{Binding ImageViewVisible, Converter={StaticResource BoolToVisibilityConverter}}"
	                                  x:Name="ImageDialogControl"/>

        <DockPanel Grid.Row="0" Grid.Column="0">
            <DockPanel DockPanel.Dock="Top" KeyboardNavigation.TabNavigation="None">
            <Menu KeyboardNavigation.TabNavigation="Cycle" FontSize="14">
                <MenuItem Header="_File">
                    <MenuItem Header="_Open..." Command="{Binding Path=OpenFileCommand}" />
                </MenuItem>
                <MenuItem Header="_Options">
                    <MenuItem Header="_Show preview bar" Command="{Binding Path=ShowPreviewCommand}" IsCheckable="True" IsChecked="{Binding PreviewVisible}" />
                </MenuItem>
                    <MenuItem Header="_Help">
                    <MenuItem Header="_About..." Command="{Binding Path=ShowAboutDialogCommand}" />
                </MenuItem>
            </Menu>
        </DockPanel>
            <Grid AllowDrop="True" DockPanel.Dock="Bottom" asfExtControls:DropBehavior.PreviewDropCommand="{Binding DropFilesCommand}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition MinWidth="10" Width="10"></ColumnDefinition>
                <ColumnDefinition Width="Auto" MinWidth="100"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <ListView Height="80"  Name="Filmstrip" ItemsSource="{Binding PreviewImages}" SelectionChanged="Filmstrip_SelectionChanged" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" ScrollViewer.VerticalScrollBarVisibility="Hidden" Visibility="{Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}" >
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"></StackPanel>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.Background>
                    <ImageBrush ImageSource="images\filmstrip.jpg"
                        Viewport="0, 0, 65, 60"
                        ViewportUnits="Absolute"
                        TileMode="Tile"
                        Stretch="None"
                        AlignmentX="Left"
                        AlignmentY="Top"  />
                </ListView.Background>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <Image Source="{Binding ThumbImage}" Style="{StaticResource FilmstripImage}" >
                                <Image.Triggers>
                                    <EventTrigger RoutedEvent="Image.MouseEnter">
                                        <BeginStoryboard Storyboard="{StaticResource expandStoryboard}" />
                                    </EventTrigger>
                                    <EventTrigger RoutedEvent="Image.MouseLeave">
                                        <BeginStoryboard Storyboard="{StaticResource shrinkStoryboard}" />
                                    </EventTrigger>
                                </Image.Triggers>
                                <Image.RenderTransform>
                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                </Image.RenderTransform>
                                <Image.RenderTransformOrigin>
                                    <Point X="0" Y="0"/>
                                </Image.RenderTransformOrigin>
                            </Image>
                            <TextBlock Margin="5 -20 0 0" Padding="3" Text="{Binding DisplayTime, Converter={StaticResource TimeToDisplayConverter} }" Foreground="White" FontSize="11" FontFamily="Arial">
                                <TextBlock.Background>
                                    <SolidColorBrush Color="Gray" Opacity="0.5" />
                                </TextBlock.Background>
                            </TextBlock>
                        </StackPanel>
                    </DataTemplate>
                    
                </ListView.ItemTemplate>
            </ListView>

                <asfView:VTreeView Grid.Row="1" Grid.Column="0" x:Name="AsfHierarchy"  
                 ItemsSource="{Binding Path=AsfObjects}"
                 VirtualizingStackPanel.IsVirtualizing="True" 
                 VirtualizingStackPanel.VirtualizationMode="Standard"
                 ScrollViewer.IsDeferredScrollingEnabled="True">
                <!--<TreeView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <asfExtControls:MyVirtualizingStackPanel/>
                    </ItemsPanelTemplate>
                </TreeView.ItemsPanel>-->
                    <TreeView.ItemContainerStyle>
                        <StaticResource ResourceKey="SelectableTreeViewItem" />
                    </TreeView.ItemContainerStyle>
                <TreeView.Resources>
                    <HierarchicalDataTemplate DataType="{x:Type asfViewModel:AsfDataObjectItem}" ItemsSource="{Binding Packets}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="images\folder_closed.png" Height="25" ></Image>
                            <TextBlock VerticalAlignment="Center" Text="{Binding Path=Name}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type asfViewModel:AsfSimpleIndexObjectItem}" ItemsSource="{Binding StreamIndexList}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="images\folder_closed.png" Height="25" ></Image>
                            <TextBlock VerticalAlignment="Center" Text="{Binding Path=Name}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type asfViewModel:AsfIndexObjectItem}" ItemsSource="{Binding StreamIndexList}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="images\folder_closed.png" Height="25" ></Image>
                            <TextBlock VerticalAlignment="Center" Text="{Binding Path=Name}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type asfParsing:StreamIndex}" ItemsSource="{Binding SeekPoints}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="images\folder_closed.png" Height="25" ></Image>
                            <TextBlock Text="Stream "/>
                            <TextBlock Text="[" />
                            <TextBlock Text="{Binding Path=StreamNumber}" />
                            <TextBlock Text="]"/>
                            <TextBlock Text="("  Margin="4 0 0 0"/>
                            <TextBlock Text="{Binding Path=SeekPoints.Count}"/>
                            <TextBlock Text=" seek points)"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type asfViewModel:AsfHeaderItem}" ItemsSource="{Binding Items}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="images\folder_closed.png" Height="25" ></Image>
                            <TextBlock VerticalAlignment="Center" Text="{Binding Path=Name}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type asfParsing:AsfIndexEntry}" ItemsSource="{Binding Packets}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="images\seekpoint.png" Height="16"></Image>
                            <TextBlock Text="Seek Point"  Margin="4 0 0 0"/>
                            <TextBlock Text="{Binding SeekPointID}"  Margin="5 0 5 0"/>
                            <TextBlock Text="-"/>
                            <TextBlock Text="{Binding Time, Converter={StaticResource TimeToDisplayConverter} }" Margin="5 0 5 0"/>
                            <TextBlock Text="Packet:"/>
                            <TextBlock Text="{Binding PacketNumber}" Margin="0 0 5 0"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                        <HierarchicalDataTemplate DataType="{x:Type asfMedia:AsfPacket}" ItemsSource="{Binding Payload}">
                        <StackPanel Orientation="Horizontal" Margin="0 1 0 1">
                            <Image Source="images\packet.png" Height="16"></Image>
                            <TextBlock Text="Packet"/>
                            <TextBlock Text="{Binding PacketID}"  Margin="5 0 5 0"/>
                            <TextBlock Text="-"/>
                            <TextBlock Text="{Binding SendTime, Converter={StaticResource TimeToDisplayConverter} }" Margin="5 0 5 0"/>
                            <TextBlock Text="Payloads:"/>
                            <TextBlock Text="{Binding Payload.Count}" Margin="0 0 5 0"/>
                            <TextBlock Text="("/>
                            <TextBlock Text="{Binding Size}"/>
                            <TextBlock Text=" bytes)"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                        <DataTemplate DataType="{x:Type asfMedia:PayloadInfo}">
                            <StackPanel Orientation="Horizontal" Margin="0 1 0 1">
                            <Image Source="images\payload.png" Height="16"></Image>
                            <TextBlock>
                                <TextBlock Text="Payload" Margin="5 0"/>
                                <TextBlock Text="{Binding PayloadId}" HorizontalAlignment="Left" Margin="5 0"></TextBlock>
                                <TextBlock Text="-"/>
                                <TextBlock Text="Stream:"/>
                                <TextBlock Text="{Binding StreamId}"  Width="13" HorizontalAlignment="Left" ></TextBlock>
                                <TextBlock Text="{Binding PresentationTime, Converter={StaticResource TimeToDisplayConverter}}" Margin="5 0 5 0"/>
                                <TextBlock Text="Object:"/>
                                <TextBlock Text="{Binding MediaObjectNumber}" MinWidth="13" HorizontalAlignment="Left" ></TextBlock>
                                <TextBlock Text="("/>
                                <TextBlock Text="{Binding PayLoadLength}"></TextBlock>
                                <TextBlock Text=" bytes)"/>
                            </TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </TreeView.Resources>
            </asfView:VTreeView>
            <GridSplitter Grid.Row="1" Grid.Column="1" Width="8" BorderThickness="1,0" Cursor="SizeWE" Background="LightGray" BorderBrush="Black"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
            </GridSplitter>
            <ScrollViewer Grid.Row="1"  Grid.Column="2" VerticalScrollBarVisibility="Auto"  HorizontalScrollBarVisibility="Auto">
                <StackPanel AllowDrop="True" HorizontalAlignment="Stretch" Name="DetailsView">
                    <ContentControl Name="HeaderObjectDetailsView"  Content="{Binding ElementName=AsfHierarchy, Path=SelectedItem}" VirtualizingStackPanel.IsVirtualizing="False">
                    <ContentControl.Resources>
                        <DataTemplate DataType="{x:Type asfViewModel:AsfContentDescriptionObjectItem}">
                            <StackPanel VerticalAlignment="Top">
                                <Border BorderBrush="LightBlue" CornerRadius="2" BorderThickness="1" Background="LightBlue">
                                    <TextBlock FontFamily="Arial" FontWeight="Bold" FontSize="20" VerticalAlignment="Center"  Margin="5 5 5 5" Text="{Binding Path=Name}" />
                                </Border>
                                <ListView ItemsSource="{Binding Properties}">
                                <ListView.View>
                                    <GridView>
                                            <GridViewColumn  HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Property" Width="180" DisplayMemberBinding="{Binding Path=Key}"/>
                                            <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Value" DisplayMemberBinding="{Binding Path=Value}"/>
                                    </GridView>
                            </ListView.View>
                            </ListView>
                                <ListView ItemsSource="{Binding EditProperties}">
                                <ListView.View>
                                    <GridView>
                                            <GridViewColumn  HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Property" Width="180" DisplayMemberBinding="{Binding Path=Key}"/>
                                            <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Value"  Width="270">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Border BorderThickness="2">
                                                            <Grid>
                                                            <TextBox Text="{Binding Path=Value, Mode=TwoWay}" Width="250"></TextBox>
                                                                <Button Name="UpdateContentProperties"  HorizontalAlignment="Right" Width="16" ToolTip="Update Content Properties" 
                                                                 Command="{Binding DataContext.UpdateContentPropertiesCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
                                                                    <Image Source="images\update.png"></Image>
                                                                </Button>
                                                            </Grid>
                                                        </Border>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                                </GridViewColumn>
                                    </GridView>
                                </ListView.View>
                            </ListView>
                                        
                                <ListView ItemsSource="{Binding Subsections}" HorizontalAlignment="Stretch">
                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <DockPanel HorizontalAlignment="Stretch">
                                                <Border DockPanel.Dock="Top" Margin="0 10 0 0" BorderBrush="LightBlue" CornerRadius="2" BorderThickness="1" Background="LightBlue" HorizontalAlignment="Stretch">
                                                    <TextBlock FontFamily="Arial" FontWeight="Bold" FontSize="12" VerticalAlignment="Center"  Margin="5 5 5 5" Text="{Binding Path=Key}" />
                                                </Border>
                                                <ListView ItemsSource="{Binding Path=Value}" MaxWidth="500">
                                                    <ListView.View>
                                                        <GridView>
                                                            <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Width="200" Header="Property" DisplayMemberBinding="{Binding Path=Key}"/>
                                                            <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Value" DisplayMemberBinding="{Binding Path=Value}"/>
                                                        </GridView>
                                                    </ListView.View>
                                                </ListView>
                                            </DockPanel>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                            </StackPanel>
                        </DataTemplate>
                        <DataTemplate DataType="{x:Type asfViewModel:AsfHeaderItem}">
                            <StackPanel VerticalAlignment="Top">
                                <Border BorderBrush="LightBlue" CornerRadius="2" BorderThickness="1" Background="LightBlue">
                                    <TextBlock FontFamily="Arial" FontWeight="Bold" FontSize="20" VerticalAlignment="Center"  Margin="5 5 5 5" Text="{Binding Path=Name}" />
                                </Border>
                                    <ListView ItemsSource="{Binding Properties}">
                                    <ListView.View>
                                        <GridView>
                                                <GridViewColumn  HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Property" Width="180" DisplayMemberBinding="{Binding Path=Key}"/>
                                                <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Value" DisplayMemberBinding="{Binding Path=Value}"/>
                                        </GridView>
                                    </ListView.View>
                                </ListView>
                                    <ListView ItemsSource="{Binding Subsections}" HorizontalAlignment="Stretch">
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                               <DockPanel HorizontalAlignment="Stretch">
                                                    <Border DockPanel.Dock="Top" Margin="0 10 0 0" BorderBrush="LightBlue" CornerRadius="2" BorderThickness="1" Background="LightBlue" HorizontalAlignment="Stretch">
                                                        <TextBlock FontFamily="Arial" FontWeight="Bold" FontSize="12" VerticalAlignment="Center"  Margin="5 5 5 5" Text="{Binding Path=Key}" />
                                                    </Border>
                                                    <ListView ItemsSource="{Binding Path=Value}" MaxWidth="500">
                                                        <ListView.View>
                                                            <GridView>
                                                                <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Width="200" Header="Property" DisplayMemberBinding="{Binding Path=Key}"/>
                                                                <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Width="270" Header="Value" DisplayMemberBinding="{Binding Path=Value}"/>
                                                            </GridView>
                                                        </ListView.View>
                                                    </ListView>
                                                </DockPanel>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                    </ListView>
                            </StackPanel>
                        </DataTemplate>                        
                        <DataTemplate DataType="{x:Type asfParsing:StreamIndex}">
                            <StackPanel VerticalAlignment="Top">
                                <Border BorderBrush="LightBlue" CornerRadius="2" BorderThickness="1" Background="LightBlue">
                                    <TextBlock FontFamily="Arial" FontWeight="Bold" FontSize="20" VerticalAlignment="Center"  Margin="5 5 5 5" Text="Stream Index" />
                                </Border>
                                    <StackPanel Orientation="Horizontal">
                                        <ListView>
                                            <ListView.View>
                                                <GridView>
                                                    <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Property" Width="180" DisplayMemberBinding="{Binding Path=Text}"/>
                                                    <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Value" DisplayMemberBinding="{Binding Path=Tag}"/>
                                                </GridView>
                                            </ListView.View>
                                            <ListViewItem>
                                                <TextBlock Text="Stream Number" Tag="{Binding StreamNumber}"/>
                                            </ListViewItem>
                                        </ListView>
                                    </StackPanel>

                            </StackPanel>
                                
                        </DataTemplate> 
                        <DataTemplate DataType="{x:Type asfParsing:AsfIndexEntry}">
                                <StackPanel VerticalAlignment="Top">
                                    <Border BorderBrush="LightBlue" CornerRadius="2" BorderThickness="1" Background="LightBlue">
                                        <TextBlock FontFamily="Arial" FontWeight="Bold" FontSize="20" VerticalAlignment="Center"  Margin="5 5 5 5">
                                            <Image Margin="0 0 0 -4"  Source="images\seekpoint.png" Height="22"></Image>
                                            <TextBlock Text="Seekpoint " Margin="4 0 0 0"/> 
                                            <TextBlock Text="{Binding SeekPointID}" />
                                            <TextBlock Text="-"/>
                                            <TextBlock Text="{Binding Time, Converter={StaticResource TimeToDisplayConverter}}" Margin="5 0 5 0"/>
                                        </TextBlock>
                                    </Border>
                                    <StackPanel Orientation="Horizontal">
                                        <ListView>
                                            <ListView.View>
                                                <GridView>
                                                    <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Property" Width="180" DisplayMemberBinding="{Binding Path=Text}"/>
                                                    <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Value" DisplayMemberBinding="{Binding Path=Tag}"/>
                                                </GridView>
                                            </ListView.View>
                                            <ListViewItem>
                                                <TextBlock Text="Seekpoint" Tag="{Binding SeekPointID}"/>
                                            </ListViewItem>
                                            <ListViewItem>
                                                <TextBlock Text="Time"  Tag="{Binding Time, Converter={StaticResource TimeToDisplayConverter}}"/>
                                            </ListViewItem>
                                            <ListViewItem>
                                                <TextBlock Text="Start Packet" Tag="{Binding PacketNumber}"/>
                                            </ListViewItem>
                                            <ListViewItem>
                                                <TextBlock Text="Packet Count" Tag="{Binding PacketCount}"/>
                                            </ListViewItem>
                                        </ListView>
                                    </StackPanel>
                                </StackPanel>
                            </DataTemplate>
                                <DataTemplate DataType="{x:Type asfMedia:AsfPacket}">
                                <StackPanel VerticalAlignment="Top">
                                    <Border BorderBrush="LightBlue" CornerRadius="2" BorderThickness="1" Background="LightBlue">
                                        <TextBlock FontFamily="Arial" FontWeight="Bold" FontSize="20" VerticalAlignment="Center"  Margin="5 5 5 5">
                                            <Image Margin="0 0 0 -4"  Source="images\packet.png" Height="22"></Image>
                                            <TextBlock Text="Packet" Margin="4 0 0 0"/>
                                            <TextBlock Text="{Binding PacketID}"  Margin="5 0 5 0"/>
                                            <TextBlock Text="-"/>
                                            <TextBlock Text="{Binding SendTime, Converter={StaticResource TimeToDisplayConverter} }" Margin="5 0 5 0"/>
                                        </TextBlock>
                                    </Border>
                                    <StackPanel Orientation="Horizontal">
                                        <ListView>
                                            <ListView.View>
                                                <GridView>
                                                    <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Property" Width="180" DisplayMemberBinding="{Binding Path=Text}"/>
                                                    <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Value" DisplayMemberBinding="{Binding Path=Tag}"/>
                                                </GridView>
                                            </ListView.View>
                                            <ListViewItem>
                                                <TextBlock Text="Packet" Tag="{Binding PacketID}"/>
                                            </ListViewItem>
                                            <ListViewItem>
                                                <TextBlock Text="Send Time (SCR)"  Tag="{Binding SendTime, Converter={StaticResource TimeToDisplayConverter}}"/>
                                            </ListViewItem>
                                            <ListViewItem>
                                                <TextBlock Text="Duration"  Tag="{Binding Duration, Converter={StaticResource TimeToDisplayConverter}}"/>
                                            </ListViewItem>
                                            <ListViewItem>
                                                <TextBlock Text="Payloads" Tag="{Binding PayloadCount}"/>
                                            </ListViewItem>
                                            <ListViewItem>
                                                <TextBlock Text="Packet Size" Tag="{Binding Size}"/>
                                            </ListViewItem>
                                            <ListViewItem>
                                                <TextBlock Text="Keyframe Start" Tag="{Binding IsKeyFrame}"/>
                                            </ListViewItem>
                                        </ListView>
                                    </StackPanel>
                                </StackPanel>
                            </DataTemplate>
                                <DataTemplate DataType="{x:Type asfMedia:PayloadInfo}">
                                        <StackPanel VerticalAlignment="Top">
                                            <Border Style="{StaticResource HeaderBorder}">
                                                <TextBlock FontFamily="Arial" FontWeight="Bold" FontSize="20" VerticalAlignment="Center"  Margin="5 5 5 5">
                                                    <Image Margin="0 0 0 -4"  Source="images\payload.png" Height="22"></Image>
                                                    <TextBlock Text="Payload " Margin="5 0"/> 
                                                    <TextBlock Text="{Binding PayloadId}" />
                                                    <TextBlock Text="-"/>
                                                    <TextBlock Text="Stream:"/>
                                                    <TextBlock Text="{Binding StreamId}"/>
                                                    <TextBlock Text="{Binding PresentationTime, Converter={StaticResource TimeToDisplayConverter}}" Margin="5 0 5 0"/>
                                                </TextBlock>
                                            </Border>
                                            <StackPanel Orientation="Horizontal">
                                                <Button Name="ButtonPrevPayload" Click="ButtonPrevPayload_Click"  Margin="2" ToolTip="Previous">
                                                    <Path Fill="DarkGreen" Margin="3" Width="15" Height="15" Data="M 1,0 L 0,1 L 1,2 Z" Stretch="Fill" StrokeLineJoin="Round"/>
                                                </Button>

                                                <ListView MinWidth="320">
                                                    <ListView.View>
                                                        <GridView>
                                                            <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Property" Width="180" DisplayMemberBinding="{Binding Path=Text}"/>
                                                            <GridViewColumn HeaderContainerStyle="{StaticResource PropertyHeader}" Header="Value" DisplayMemberBinding="{Binding Path=Tag}"/>
                                                        </GridView>
                                                    </ListView.View>
                                                    <ListViewItem>
                                                        <TextBlock Text="Payload" Tag="{Binding PayloadId}"/>
                                                    </ListViewItem>
                                                    <ListViewItem>
                                                        <TextBlock Text="Stream ID" Tag="{Binding StreamId}"/>
                                                    </ListViewItem>
                                                    <ListViewItem>
                                                        <TextBlock Text="Object ID" Tag="{Binding MediaObjectNumber}"/>
                                                    </ListViewItem>
                                                    <ListViewItem>
                                                        <TextBlock Text="Object Offset" Tag="{Binding OffsetIntoMedia}"/>
                                                    </ListViewItem>
                                                    <ListViewItem>
                                                        <TextBlock Text="Payload Length" Tag="{Binding PayLoadLength}"/>
                                                    </ListViewItem>
                                                    <ListViewItem>
                                                        <TextBlock Text="Presentation Time" Tag="{Binding PresentationTime, Converter={StaticResource TimeToDisplayConverter}}"/>
                                                    </ListViewItem>
                                                    <ListViewItem>
                                                        <TextBlock Text="Key Frame" Tag="{Binding IsKeyframeStart}"/>
                                                    </ListViewItem>
                                                </ListView>
                                                <Button Name="ButtonNextPayload" Click="ButtonNextPayload_Click"  Command="{Binding Path=NextPayloadCommand, Source={StaticResource Locator}}" CommandParameter="{Binding PayloadId}" Margin="2" ToolTip="Next">
                                                    <Path Fill="DarkGreen" Margin="3" Width="15" Height="15" Data="M 0,0 L 1,1 L 0,2 Z" Stretch="Fill" StrokeLineJoin="Round"/>
                                                </Button>
                                        </StackPanel>
                                        <StackPanel HorizontalAlignment="Left" Margin="28 10 0 0" Visibility="{Binding HasVideoStream, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource BoolToVisibilityConverter}}"> 
                                                <Grid>
                                                    <StackPanel>
                                                    <Border BorderBrush="Black" BorderThickness="1" >
                                                        <Image Name="timeImage" Width="320" MouseWheel="timeImage_MouseWheel" Source="{Binding PresentationTime, Converter={StaticResource TimeToImageConverter}, IsAsync=True}" MouseDown="timeImage_MouseDown">
                                                            <Image.InputBindings>
                                                                <MouseBinding Command="{Binding Path=ShowImageDialogCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" MouseAction="LeftDoubleClick" />
                                                            </Image.InputBindings>
                                                        
                                                            <Image.ContextMenu>
                                                                <ContextMenu>
                                                                    <MenuItem Header="Copy" InputGestureText="Ctrl+C" Command="{Binding Path=ExportImageCommand}"  DataContext="{Binding Main, Source={StaticResource Locator}}" />
                                                                </ContextMenu>
                                                            </Image.ContextMenu>
                                                        </Image>
                                                    </Border>
                                                </StackPanel>
                                                </Grid>
                                        </StackPanel>
                                        <StackPanel Margin="28 0 0 0">
                                            <asfView:WaveFormControl HorizontalAlignment="Left" BorderBrush="Black" x:Name="WaveFormDisplay" Width="{Binding ElementName=timeImage, Path=Width}" Height="100" Tag="{Binding PresentationTime}" Visibility="Visible"/>
                                        </StackPanel>
                                    </StackPanel>
                            </DataTemplate>
                    </ContentControl.Resources>
                </ContentControl>
                </StackPanel>
            </ScrollViewer>
        </Grid >
        </DockPanel>
    </Grid>

</Window>
